<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Lista de Todos os Telefones Cadastrados</title>
<link rel="stylesheet" href="../style/estilo.css" type="text/css">
</head>
<body>
	<form id="form" action="manterTipoTelefone" method="post">
		<div id="error">
		<c:if test="${error != null}">
			<c:out value="${error}" />
		</c:if>
		</div>
		<div id="info">
		<c:if test="${info != null}">
			<c:out value="${info}" />
		</c:if>
		</div>
		<input type="hidden" name="method" value="listar"/>
		<input type="hidden" name="id" />
		<c:if test="${not empty lista}">
			<table border="1">
				<tr>
					<th>Descriao</th>
					<th>Data Cadastro</th>
				</tr>
				<c:forEach items="${lista}" var="tipoTelefone">
					<tr>
						<td>
							<c:out value="${tipoTelefone.descricao}" />
						</td>
						<td>
							<fmt:formatDate value="${tipoTelefone.dataCadastro}" pattern="dd/MM/yyyy"/>
						</td>
						<td>
							<a onclick="excluir(${tipoTelefone.id});">excluir</a>
						</td>
					</tr>
				</c:forEach>
			</table>
		</c:if>
		
		<c:if test="${empty lista}">
			<h3>Nenhum dado encontrado!</h3>
		</c:if>
		
	</form>
	
</body>
<script type="text/javascript">
	function excluir(id){
		if(confirm("Deseja realmente excluir este item?")){
			var form = document.forms["form"];
			form.action.value="manterTipoTelefone";
			form.id.value = id;
			form.method.value="excluir";
			form.submit();
		}
	}
</script>
</html>